//
// Created by root on 4/29/17.
//

#ifndef FUNNY_CMOCKA_TEST_H
#define FUNNY_CMOCKA_TEST_H

#include <stdio.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>

#ifdef cmocka_run_group_tests
#undef cmocka_run_group_tests
#endif
# define cmocka_run_group_tests(group_tests, group_setup, group_teardown) \
        _cmocka_run_group_tests(#group_tests, group_tests, sizeof(group_tests) / sizeof(group_tests[0]), group_setup, group_teardown)

/**
 * macro definition of funny stubs
 */
#define WRAP_MACRO_FUNC1(func) char* __wrap_ ## func \
    (Statement *s1); \
char* __wrap_ ## func \
    (Statement *s1) {check_expected(s1);return (char*)mock();}

#define WRAP_MACRO_FUNC2(func) char* __wrap_ ## func \
    (Statement *s1,Statement *s2); \
char* __wrap_ ## func \
    (Statement *s1,Statement *s2) {check_expected(s1);check_expected(s2);return (char*)mock();}

#define WRAP_MACRO_FUNC3(func) char* __wrap_ ## func \
    (Statement *s1,Statement *s2,Statement *s3); \
char* __wrap_ ## func \
    (Statement *s1,Statement *s2,Statement *s3) {check_expected(s1);check_expected(s2);check_expected(s3);return (char*)mock();}

#define WRAP_MACRO_FUNC4(func) char* __wrap_ ## func \
    (Statement *s1,Statement *s2,Statement *s3,Statement *s4); \
char* __wrap_ ## func \
    (Statement *s1,Statement *s2,Statement *s3,Statement *s4) {check_expected(s1);check_expected(s2);check_expected(s3);check_expected(s4);return (char*)mock();}

#endif //FUNNY_CMOCKA_TEST_H
